package com.bjesc_b2c.app.appraiset.widget.popupwindow;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.widget.BasePopupWindow;

import static com.bjesc_b2c.app.appraiset.R.id.tv_car_number;
import static com.bjesc_b2c.app.appraiset.R.id.tv_car_vin;

/**
 * Created by yidong on 2017/8/7.
 */

    public class TrackPop extends BasePopupWindow {
        private TextView tv_car_name, tv_client_name, tv_order_id;
        public int popupWidth;
        public int popupHeight;
        public TrackPop(Context context, View.OnClickListener listener ) {
            super(context, listener);
        }

        @Override
        protected void initViews() {
            view = inflater.inflate(R.layout.layout_track_pop, null);
            tv_car_name = (TextView) view.findViewById(R.id.tv_car_name);
            tv_client_name = (TextView) view.findViewById(R.id.tv_client_name);
            tv_order_id = (TextView) view.findViewById(R.id.tv_order_id);
            tv_car_name.setOnClickListener(listener);
            tv_order_id.setOnClickListener(listener);
            tv_client_name.setOnClickListener(listener);
            view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);//这句很重要 不是获取不到宽高
            popupHeight = view.getMeasuredHeight();
            popupWidth = view.getMeasuredWidth();
        }

        @Override
        protected void setView() {
            super.setView();
            this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        }
        @Override
        protected int setRootViewId() {
            return R.id.root;
        }

        public void showAtView(View parent) {
            int[] location = new int[2];
            parent.getLocationOnScreen(location);
            showAtLocation(parent, Gravity.NO_GRAVITY, (location[0] + parent.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);
        }
    }


